The present disclosure relates to managing the backing of virtual memory with real memory, and in particular to pre-backing virtual memory with real memory based on learned data regarding memory utilization.
Most if not all computer systems use virtual memory to simulate more real storage to the user than is possible to physically have. As such, an operating system's (OS) memory or storage manager working with system hardware must ensure that a virtual storage page be associated or backed by real system storage in order for it to be used by the computer hardware.
In general, a real storage manager (RSM) controls the use of real storage and directs the movement of virtual pages between auxiliary storage and real storage. The RSM makes all addressable virtual storage appear as real or physical storage to a user, while only the virtual pages necessary for execution are kept in real storage, these pages are often referred to as being backed. This backing is required when a virtual page is referenced or in some systems some of the virtual storage is backed when the storage is requested to be allocated by the user program or application.
The RSM assigns real storage frames on request from a virtual storage manager (VSM), which manages the allocation of virtual storage pages, and the RSM determines a size of memory that will be allocated to back a virtual storage page. Examples of memory backing sizes include 4 kB, 1 MB, and 2 GB. Software applications using larger segments of virtual storage, such as multiple Mbytes, can achieve measurable performance improvement if these segments are backed by larger page frames in real memory, such as the 2 GB page frame.
During memory allocation, some portion of the virtual storage allocation is backed in the real memory. For example, a request to allocate 8K of virtual memory can result in the first 4 k being backed immediately while the second 4 k is not. The assumption is that the program requesting the virtual storage will use the first page immediately so it is best for performance to just back it. Another way that a virtual page is backed in the real memory is when a page fault occurs. In this case, the hardware causes an interrupt because the dynamic address translation (DAT) for the virtual page resulted in no real frame backing the virtual page. This interrupt drives RSM to back the page immediately which also results in the DAT tables being updated so the hardware can find the backing page. In general, page fault faults are expensive in terms of time and computing resources.
In current systems, the RSM does not know what pages the application will need in advance, so it cannot optimize by backing additional pages ahead of when they are needed. As a result, when the program often experiences reference pages faults as it touches its storage during execution, the time required to back the storage also elongates the time between sections of the application's execution time as the OS is running. This, in turn, leads to clearing the application's data from L1/L2 cache before it executes again.
In addition, the use of large memory pages rather than small ones by the VSM increases performance as the processor does not need as many Table Look aside Buffer (TLB) entries for the same storage range because there is only one entry per page. As such, using larger pages are beneficial if the storage is used and can cause fragmentation if not used. For example, if the application requests 4 GB of virtual storage but only uses the 1st 8 k then two 4 k pages would be better than using 2 GB to back the 8 k.